/*
 * Copyright 2012 Andrea Parodi
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */

package eban.storebyrules;

/**
 * A transaction is responsible to
 * group a set of commands for the
 * Storage, and later execute them
 * at the calling of commit method.
 * <p>
 * A transaction is granted to succeed
 * completely or to leave the state
 * of the storage engine as it was
 * before it's execution.
 *
 * A transaction represent a unit of work
 * that allow client code to alter the storage
 * system state.
 * <p>
 * It's possible for client code to alter the state of a storage
 * by calling it's execute method one or more time.
 * When data command are executed, it's possible to call
 * the commit method to execute all commands in database and
 * then dispose the transaction.
 * <p>
 * It's otherwise possible to call rollback method to dispose
 * the transaction without running any command.
 * <p>
 * Users of Transaction objects are always required
 * to dispose the transaction by calling rollback or
 * commit. Owner DbManager should keep track on this and
 * throw an exception in its close method if it has
 * non disposed owned transactions.
 *
 */
public interface Transaction {
    void execute(String sql);
    void commit();
    void rollback();
    void dispose();
}
